package com.wyz.controller;

import com.wyz.mapper.SystemAdminMapper;
import com.wyz.model.SystemAdmin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author wk
 * @desc
 * @date 2024/7/28 14:08
 */
@Controller
public class SyetemAdminController {
    @Resource
    private SystemAdminMapper systemAdminMapper;
    @RequestMapping("/systemAdmin/getAllSystemAdmin")
    public String getAllSystemAdmin(HttpSession session) {
        List<SystemAdmin> systemAdmins= systemAdminMapper.selectList(null);
        session.setAttribute("systemAdmins",systemAdmins);
        return "back/system";
    }
    @RequestMapping("/systemAdmin/deleteById")
    public String deleteById(Integer id) {
        systemAdminMapper.deleteById(id);
        return "redirect:/systemAdmin/getAllSystemAdmin";
    }
    @RequestMapping("/systemAdmin/addSystemAdmin")
    public String addSystemAdmin() {
        return "back/systemUserAdd";
    }
    @RequestMapping("/systemAdmin/addSystemAdminHandler")
    public String addSystemAdminHandler(SystemAdmin systemAdmin) {
        systemAdminMapper.insert(systemAdmin);
        return "redirect:/systemAdmin/getAllSystemAdmin";
    }


}
